import request from '@/utils/request'
import qs from 'qs'

// 获取菜品属性
export function findFoodAttribute (foodAttributeId) {
  return request({
    url: '/food/food_attribute/find_food_attribute',
    method: 'get',
    params: {
      foodAttributeId,
      storeId: sessionStorage.getItem('storeId')
    }
  })
}

/**
 * 添加菜品属性
 * @param foodAttributeId 菜品属性id，做法、口味、规格、称重的id
 * @param name 菜品属性详情名称，做法下的加糖、加盐等
 */
export function addFoodAttribute (foodAttributeId, name) {
  return request({
    url: '/food/food_attribute_detail/save',
    method: 'post',
    data: qs.stringify({
      storeId: sessionStorage.getItem('storeId'),
      foodAttributeId,
      name
    })
  })
}

/**
 * 修改菜品属性
 * @param foodAttributeDetailId 菜品属性id，做法、口味、规格、称重的id
 * @param name 菜品属性详情名称，做法下的加糖、加盐等
 */
export function editFoodAttribute (foodAttributeDetailId, name) {
  return request({
    url: '/food/food_attribute_detail/update',
    method: 'post',
    data: qs.stringify({
      id:foodAttributeDetailId,
      name
    })
  })
}

/**
 * 删除菜品属性
 * @param foodAttributeDetailId 菜品属性详情id
 */
export function deleteFoodAttribute (foodAttributeDetailId) {
  return request({
    url: '/food/food_attribute_detail/delete',
    method: 'post',
    data: qs.stringify({
      ids: foodAttributeDetailId
    })
  })
}

/**
 * 添加菜品获取门店属性列表
 * @param foodAttributeDetailId 菜品属性详情id
 */
export function findStoreFoodAttribute () {
  return request({
    url: '/food/food_attribute/find_store_food_attribute',
    method: 'get',
    params: {
      storeId: sessionStorage.getItem('storeId'),
    }
  })
}

